export const magic = [
  4,3,8,
  9,5,1,
  2,7,6
]
export const checkWinner = (steps = [], play = "X") => {
  let lines = []
  let gameStatus = ""
  let gameover = false
  steps.sort(function (a,b) {
    return a - b
  })
  for (let i = 0; i < steps.length; i++) {
    for (let x = 0; x < steps.length; x++) {
      for (let y = 0; y < steps.length; y++) {
        if (steps[x] + steps[y] + steps[i] === 15 && i < x && x < y) {
          lines = [
            magic.indexOf(steps[i]),
            magic.indexOf(steps[x]),
            magic.indexOf(steps[y]),
          ]
          gameStatus = `Winner is: ${play}!!!`
          gameover = true
          break
        }
        // [].every()
        if((steps.length === 5) && (!gameover)){
          gameStatus = "啊这。。。。"
        }
      }
    }
  }
  return {
    lines,
    gameStatus,
    gameover
  }
}
